package com.ruoyi.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.domain.UserMonitoring;
import com.ruoyi.service.UserMonitoringService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

/**
 * 用户-健康监测数据
 *
 * @author lifei
 * @ClassName UserMonitoring
 */

@RestController
@RequestMapping("/kangyue/usermonitoring")
public class UserMonitoringController extends BaseController {

    @Autowired
    private UserMonitoringService userMonitoringService;

    /**
     * 获取最近五次血压数据
     */
    @GetMapping("/lastfivebloodpressure")
    public TableDataInfo getLastFiveBloodPressures(@RequestParam Long userId) {
        List<UserMonitoring> list = userMonitoringService.selectLastFiveBloodPressure(userId);
        return getDataTable(list);
    }

    /**
     * 获取用户五分钟内五次心率数据
     * @param userId 用户ID
     * @return 血压数据列表
     */
    @GetMapping("/lastfiveheartrate")
    public TableDataInfo getLastFiveHeartRate(@RequestParam long userId) {
        List<UserMonitoring> list = userMonitoringService.selectLastFiveHeartRate(userId);
        return getDataTable(list);
    }

    /**
     * 获取最近五个月体重数据
     */
    @GetMapping("/lastFiveMonthsWeight")
    public AjaxResult getLastFiveMonthsWeight(@RequestParam Long userId) {
        Map<String, List<UserMonitoring>> result = userMonitoringService.getLastFiveMonthsWeight(userId);
        return AjaxResult.success(result);
    }
}

